package com.booza.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

public class ConverterUtil
{
	@SuppressWarnings("rawtypes")
	public static String listToSQLString(List list)
	{
		StringBuilder temp = new StringBuilder();

		if (list == null || list.isEmpty()) {
			return "";
		}

		int max = list.size() - 1;
		temp.append("(");
		for (int i = 0; i < max; i++) {
			temp.append(list.get(i));
			temp.append(",");
		}
		temp.append(list.get(max));
		temp.append(")");
		return temp.toString();
	}

	public static String dateInUserTimezone(Date d, String zoneName, String formatTemplate)
	{
		DateFormat f = null;
		String formated;

		if (formatTemplate == null) {
			f = new SimpleDateFormat("dd/MM/yyyy HH:mm");
		}
		else {
			f = new SimpleDateFormat(formatTemplate);
		}
		
		f.setTimeZone(TimeZone.getTimeZone(zoneName));
		formated = f.format(d);
		return formated;
	}
}
